import { getAgentInfoListByName, getByName } from '@/services/backend/agentInfoController';
import { getBasicSettingsByUserId } from '@/services/backend/basicSettingsController';
import { addOrUpdateComplaintInfo } from '@/services/backend/complaintInfoController';
import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
import {
  ProCard,
  ProForm,
  ProFormDatePicker,
  ProFormDependency,
  ProFormInstance,
  ProFormRadio,
  ProFormSelect,
  ProFormText,
  ProFormTextArea,
  StepsForm,
} from '@ant-design/pro-components';
import '@umijs/max';
import { useModel } from '@umijs/max';
import { Button, Form, Input, message, Modal, Space, Typography } from 'antd';
import React, { useEffect, useRef, useState } from 'react';

interface Props {
  modalVisible: boolean;
  onSubmit: () => void;
  onCancel: () => void;
}

const sourceEnumMap = new Map([
  ['投诉、举报', '投诉、举报'],
  ['其他部门移送', '其他部门移送'],
  ['上级交办', '上级交办'],
]);

const CreateModal: React.FC<Props> = (props) => {
  const { modalVisible, onSubmit, onCancel } = props;

  //表单引用
  const formMapRef = useRef<React.MutableRefObject<ProFormInstance<any> | undefined>[]>([]);
  // 添加状态来存储争议事实
  const [complaintDescValue, setComplaintDescValue] = useState<string>('暂无争议事实');
  // 添加状态来存储联系人姓名
  const [contactPerson, setContactPerson] = useState<string>();
  // 添加状态来存储统一社会信用代码
  const [creditCode, setCreditCode] = useState<string>('暂无统一社会信用代码');

  //联系人List
  const [contactsList, setContactsList] = useState<API.Contacts[]>([]);
  // 联系人与电话的映射关系
  const [contactPhoneMap, setContactPhoneMap] = useState<Map<string, string>>();
  // (立案审批)联系人电话List
  const [contactPhoneList, setContactPhoneList] = useState([]);
  // (立案审批)联系人名字List
  const [contactNameList, setContactNameList] = useState([]);
  // 添加状态来存储举报方式
  const [way, setWay] = useState<string>('投诉举报信');
  // 添加表单引用
  const formRef = useRef<any>();
  const { initialState } = useModel('@@initialState');
  const { currentUser } = initialState || {};

  const [complaintBaseInfoVo, setComplaintBaseInfoVo] = useState<API.ComplaintBaseInfoVo>({});

  //代理人信息
  const [info, setInfo] = useState<API.ComplaintBaseInfoVo>({});

  // 联系人与电话的映射关系
  // const contactPhoneMap = {
  //   吴家豪: '10086',
  //   周星星: '10087',
  //   陈拉风: '10088',
  // };

  const loadContactPhoneMap = async () => {
    try {
      const res = await getBasicSettingsByUserId({
        //@ts-ignore
        userId: currentUser.id,
      });

      //@ts-ignore
      setComplaintBaseInfoVo(res.data);

      // 修改needMap的生成方式，使其结构与注释中的示例一致
      const needMap = {};
      let needPhoneList = [];
      let neednameList = [];
      if(res.data?.contactsList != null) {
        res.data?.contactsList?.forEach((contact: API.Contacts) => {
          // @ts-ignore
          needMap[contact.name] = contact.phone;
        });
  
        needPhoneList = res.data?.contactsList.map((contact: API.Contacts) => {
          return contact.name;
        });
  
        neednameList = res.data?.contactsList.map((contact: API.Contacts) => {
          return contact.phone;
        });
      }

      setContactPhoneList(needPhoneList);
      setContactNameList(neednameList);
      //@ts-ignore
      setContactPhoneMap(needMap);
    } catch (e: any) {
      message.error(e.message);
    }
  };

  //初始化
  useEffect(() => {
    const init = async () => {
      await loadContactPhoneMap();
      //设置值
      setInfo({
        ...complaintBaseInfoVo,
        contactPerson,
        creditCode,
      });
    };

    init();
  }, []);

  // 使用另一个 useEffect 监听 info 的变化，用于设置表单值
  useEffect(() => {
    if (Object.keys(info).length > 0 && formMapRef.current) {
      // 设置表单值
      formMapRef?.current?.forEach((formInstanceRef) => {
        if (formInstanceRef?.current) {
          formInstanceRef.current.setFieldsValue(info);
        }
      });
    }
  }, [info]);

  /**
   * @en-US Add node
   * @zh-CN 添加节点
   * @param fields
   */
  // 修改 handleAdd 函数，确保数据正确映射
  const handleAdd = async (fields: any) => {
    const hide = message.loading('正在添加');
    try {
      // 构建 ComplaintBaseInfoVo 对象

      //方法一： 根据phone获取id
      // const needContactPhone = fields.contactPhone;
      // console.log(fields);
      // console.log('needContactPhone', needContactPhone);
      // // 从complaintBaseInfoVo中获取联系人列表
      // //@ts-ignore
      // const contactsFromBasicInfo = complaintBaseInfoVo.contactsList || [];

      // // 根据电话号码找到对应的联系人ID
      // const contactIds = needContactPhone
      //   ? needContactPhone
      //       .map((phone: string) => {
      //         const contact = contactsFromBasicInfo.find((c: API.Contacts) => c.phone === phone);
      //         return contact ? contact.id : null;
      //       })
      //       .filter(Boolean)
      //   : [];

      // // 将ID列表转换为逗号分隔的字符串
      // const contactsId = contactIds.join(',');

      //方法二：根据name获取id
      const needContactPerson = fields.contactPerson;
      // 从complaintBaseInfoVo中获取联系人列表
      //@ts-ignore
      const contactsFromBasicInfo = complaintBaseInfoVo.contactsList || [];

      // 根据电话号码找到对应的联系人ID
      const contactIds = needContactPerson
        ? needContactPerson
            .map((phone: string) => {
              const contact = contactsFromBasicInfo.find((c: API.Contacts) => c.name === phone);
              return contact ? contact.id : null;
            })
            .filter(Boolean)
        : [];

      // 将ID列表转换为逗号分隔的字符串
      const contactsId = contactIds.join(',');

      //获取complainDesc = A(固定) + B + C
      const complaintDesc = '我局接到' + fields.way + '，投诉举报' + info.agentInfo?.name + fields.complaintDetail;

      const complaintData: API.ComplaintBaseInfoVo = {
        ...fields,
        complaintDesc,
        departmentId: currentUser.departmentId,
        // 确保嵌套对象正确映射
        complainantInfo: fields.complainantInfo,
        agentInfo: info.agentInfo,
        transferDepartmentDto: {
          ...fields.transferDepartmentDto,
          contactsList: contactsList,
        },
        contactsId,
        contactPhone: '',
        contactPerson: '',
        registerAcceptance: fields.registerAcceptance,
      };
      console.log(complaintData);
      // await addComplaintUsingPost(complaintData);
      await addOrUpdateComplaintInfo({
        ...complaintData,
      });
      hide();
      message.success('创建成功');
      return true;
    } catch (error: any) {
      hide();
      message.error(`创建失败,${error.message}`);
      return false;
    }
  };

  return (
    <StepsForm
      formRef={formRef}
      formMapRef={formMapRef}
      onFinish={async (values) => {
        const success = await handleAdd(values);
        if (success) {
          onSubmit?.();
          return true;
        }
      }}
      formProps={{
        validateMessages: {
          required: '此项为必填项',
        },
      }}
      stepsFormRender={(dom, submitter) => {
        return (
          <Modal
            title={'新建'}
            width={900}
            open={modalVisible}
            destroyOnClose
            footer={submitter}
            onCancel={onCancel}
          >
            <div>{dom}</div>
          </Modal>
        );
      }}
    >
      <StepsForm.StepForm
        name={'basic'}
        title="基本信息"
        onValuesChange={async (changedValues) => {
          //如果选择了`被举报人名称`,那么获取id,查询,渲染下面的数据
          if (changedValues?.agentInfo?.name) {
            try {
              const res = await getByName({
                name: changedValues.agentInfo.name,
              });
              const agentInfo = res.data as API.AgentInfo;
              //渲染
              setInfo({
                ...info,
                agentInfo,
              });
              setCreditCode(agentInfo.creditCode);
              setContactPerson(agentInfo.contactPerson);
            } catch (e: any) {
              message.error(e.message);
            }
          }
        }}
      >
        <ProFormSelect
          label="来源分类"
          width="sm"
          name={['source']}
          initialValue={'投诉、举报'}
          valueEnum={sourceEnumMap}
          rules={[{ required: true, message: '请选择来源分类' }]}
        />
        {/* 移送、交办部门信息 */}
        <ProFormDependency name={['source']}>
          {({ source }) => {
            if (source !== '投诉、举报') {
              return (
                <ProCard
                  title="移送、交办部门信息"
                  bordered
                  headerBordered
                  collapsible
                  style={{
                    marginBlockEnd: 16,
                    minWidth: 700,
                    maxWidth: '100%',
                  }}
                >
                  <ProFormText
                    name={['transferDepartmentDto', 'name']}
                    width="md"
                    label="部门名称"
                    placeholder="请输入部门名称"
                    rules={[
                      { required: true, message: '请输入部门名称' },
                      { max: 20, message: '部门名称不能超过20个字符' },
                    ]}
                  />
                  <Form
                    style={{ marginBottom: 50 }}
                    name="dynamic_form_nest_item"
                    onValuesChange={(changedValues, allValues) => {
                      console.log(allValues);
                      setContactsList(allValues.transferDepartmentDto.contactsList);
                    }}
                    autoComplete="off"
                  >
                    <Form.List name={['transferDepartmentDto', 'contactsList']} initialValue={[{}]}>
                      {(fields, { add, remove }) => (
                        <>
                          {fields.map(({ key, name, ...restField }) => (
                            <Space
                              key={key}
                              style={{ display: 'flex', marginBottom: 20, alignItems: 'flex-end' }}
                              align="baseline"
                            >
                              <Form.Item
                                label={'联系人'}
                                {...restField}
                                name={[name, 'name']}
                                rules={[
                                  { required: true, message: '不能为空' },
                                  { max: 20, message: '联系人姓名不能超过20个字符' },
                                ]}
                              >
                                <Input placeholder="请输入联系人" />
                              </Form.Item>
                              <Form.Item
                                label={'联系电话'}
                                {...restField}
                                name={[name, 'phone']}
                                rules={[
                                  { required: true, message: '不能为空' },
                                  { pattern: /^[0-9\-]+$/, message: '联系电话只能包含数字和-' },
                                  { max: 20, message: '联系电话不能超过20个字符' },
                                ]}
                                tooltip={'若输入相同的联系电话,则只保留一个'}
                              >
                                <Input placeholder="请输入联系电话" />
                              </Form.Item>
                              <CloseOutlined
                                onClick={() => {
                                  //获取当前的List
                                  //若只有一个,则不能再删除
                                  if (contactsList.length <= 1) {
                                    message.warning('请至少保留1个联系人');
                                    return;
                                  }
                                  //否则,可以删除
                                  remove(name);
                                }}
                              />
                            </Space>
                          ))}
                          <Form.Item style={{ marginTop: 30 }}>
                            <Button
                              type="dashed"
                              onClick={() => add()}
                              block
                              icon={<PlusOutlined />}
                            >
                              新增联系人
                            </Button>
                          </Form.Item>
                        </>
                      )}
                    </Form.List>
                  </Form>
                  <ProFormTextArea
                    name={['transferDepartmentDto', 'address']}
                    label="联系地址"
                    width="lg"
                    placeholder="请输入联系地址"
                    rules={[
                      { required: true, message: '请输入联系地址' },
                      { max: 1000, message: '联系地址不能超过1000个字符' },
                    ]}
                  />
                </ProCard>
              );
            }
            return null;
          }}
        </ProFormDependency>
        <ProCard
          title="投诉立案"
          bordered
          headerBordered
          collapsible
          style={{
            marginBlockEnd: 16,
            minWidth: 700,
            maxWidth: '100%',
          }}
        >
          <ProFormText
            name={['complainantInfo', 'name']}
            width="md"
            label="投诉举报人姓名"
            placeholder="请输入投诉举报人姓名"
            rules={[
              { required: true, message: '请输入投诉举报人姓名' },
              { max: 20, message: '投诉举报人姓名不能超过20个字符' },
            ]}
          />
          <ProFormText
            name={['complainantInfo', 'idNo']}
            width="md"
            label="身份证号码"
            placeholder="请输入身份证号码"
            rules={[{ pattern: /^[0-9]{18}$/, message: '请输入正确的身份证号码' }]}
          />
          <ProFormText
            name={['complainantInfo', 'phone']}
            width="md"
            label="联系电话"
            placeholder="请输入联系电话"
            rules={[
              { required: true, message: '请输入联系电话' },
              //@ts-ignore
              { pattern: /^[0-9]+$/, message: '联系电话只能包含数字' },
            ]}
          />
          <ProFormTextArea
            name={['complainantInfo', 'address']}
            label="联系地址"
            width="md"
            placeholder="请输入联系地址"
            rules={[
              { required: true, message: '请输入联系地址' },
              { max: 100, message: '联系地址不能超过100个字符' },
            ]}
          />
        </ProCard>
        <ProCard
          title="被投诉举报人信息"
          bordered
          headerBordered
          collapsible
          style={{
            marginBlockEnd: 16,
            minWidth: 700,
            maxWidth: '100%',
          }}
        >
          <ProFormSelect
            name={['agentInfo', 'name']}
            width="md"
            label="被举报人名称"
            showSearch
            debounceTime={300}
            placeholder="请输入被举报人名称"
            rules={[{ required: true, message: '请输入被举报人名称' }]}
            request={async ({ keyWords }) => {
              try {
                const res = await getAgentInfoListByName({
                  name: keyWords,
                });
                return res.data?.map((item: API.AgentInfo) => {
                  return {
                    label: item.name,
                    value: item.name,
                  };
                });
              } catch (e: any) {
                message.error(e.message);
              }
            }}
          />
          <ProFormDependency name={['agentInfo', 'name']}>
            {({ agentInfo }) => {
              return (
                <>
                  <ProFormText
                    name={['agentInfo', 'creditCode']}
                    width="md"
                    label="统一社会信用代码"
                    disabled
                    placeholder="请输入统一社会信用代码"
                    fieldProps={{
                      onChange: (e) => {
                        setCreditCode(e.target.value);
                      },
                    }}
                    rules={[{ required: true, message: '请输入统一社会信用代码' }]}
                  />
                  <ProFormTextArea
                    name={['agentInfo', 'address']}
                    label="被举报人地址"
                    width="md"
                    disabled
                    placeholder="请输入被举报人地址"
                    rules={[{ required: true, message: '请输入被举报人地址' }]}
                  />
                  <ProFormText
                    name={['agentInfo', 'contactPerson']}
                    width="md"
                    label="联系人姓名"
                    disabled
                    placeholder="请输入联系人姓名"
                    rules={[{ required: true, message: '请输入联系人姓名' }]}
                    fieldProps={{
                      onChange: (e) => {
                        console.log(e.target.value);
                        setContactPerson(e.target.value);
                      },
                    }}
                  />
                  <ProFormText
                    name={['agentInfo', 'contactPhone']}
                    width="md"
                    label="联系电话"
                    disabled
                    placeholder="请输入联系电话"
                    rules={[{ required: true, message: '请输入联系电话' }]}
                  />
                </>
              );
            }}
          </ProFormDependency>
        </ProCard>
        <ProCard
          title="投诉举报明细"
          bordered
          headerBordered
          collapsible
          style={{
            marginBlockEnd: 16,
            minWidth: 700,
            maxWidth: '100%',
          }}
        >
          <ProFormDatePicker
            name={['complaintDate']}
            label="接收日期"
            width="md"
            placeholder="请选择接收日期"
            rules={[{ required: true, message: '请选择接收日期' }]}
          />
          <ProForm.Item
            name="complaintDesc"
            label="争议事实"
            rules={[
              { required: true, message: '请输入争议事实' },
              { max: 1000, message: '争议事实不能超过1000个字符' },
            ]}
          >
            <div style={{ display: 'flex', flexDirection: 'column' }}>
              <div style={{ display: 'flex', alignItems: 'center', marginBottom: '8px' }}>
                <span style={{ marginRight: '8px' }}>我局接到</span>
                <ProFormText
                  name={['way']}
                  width="sm"
                  placeholder="投诉举报信"
                  noStyle
                  fieldProps={{
                    onChange: (e) => {
                      console.log(e.target.value);
                      setWay(e.target.value);
                    },
                  }}
                />
                <span style={{ margin: '0 8px' }}>，投诉举报</span>
                <ProFormText
                  name={['agentInfo', 'name']}
                  dependencies={['agentInfo', 'name']}
                  width="sm"
                  disabled
                  placeholder="请填写被举报人名称"
                  noStyle
                />
              </div>
              <ProFormTextArea
                name="complaintDetail"
                width="xl"
                placeholder="请输入争议事实详情"
                fieldProps={{
                  onChange: (e) => {
                    setComplaintDescValue(`涉嫌${e.target.value}案`);
                    setInfo({
                      ...info,
                      registerAcceptance: {
                        cause: `涉嫌${e.target.value}案`,
                      },
                    });
                  },
                }}
              />
            </div>
          </ProForm.Item>
        </ProCard>
      </StepsForm.StepForm>
      <StepsForm.StepForm name="accept" title="立案审批">
        <ProForm.Group>
          <ProForm.Item
            name={['isAcceptance']}
            label="受理结果"
            rules={[{ required: true, message: '请选择受理结果' }]}
          >
            <div style={{ display: 'flex', alignItems: 'center' }}>
              <ProFormRadio.Group
                name={['isAcceptance']}
                formItemProps={{
                  initialValue: '0',
                }}
                options={[
                  {
                    label: '不予受理',
                    value: '0',
                  },
                  {
                    label: '受理投诉',
                    value: '1',
                  },
                ]}
              />
            </div>
          </ProForm.Item>
          <ProFormDatePicker
            name={['acceptanceDate']}
            label="处理日期"
            width="md"
            placeholder="请选择处理日期"
            rules={[{ required: true, message: '请选择处理日期' }]}
          />
          <ProFormDependency name={['isAcceptance']}>
            {({ isAcceptance }) => {
              if (isAcceptance === '0') {
                return (
                  <ProForm.Item
                    name="acceptanceSituation"
                    label="不受理投诉所属情形"
                    rules={[{ required: true, message: '请选择不受理投诉所属情形' }]}
                  >
                    <div style={{ display: 'flex', flexDirection: 'column' }}>
                      <div style={{ display: 'flex', alignItems: 'baseline' }}>
                        <span style={{ marginRight: '8px' }}>经审查，属以下第</span>
                        <ProFormSelect
                          name={['acceptanceSituation']}
                          width="xs"
                          placeholder="请选择"
                          options={[
                            { label: '一', value: '一' },
                            { label: '二', value: '二' },
                            { label: '三', value: '三' },
                            { label: '四', value: '四' },
                            { label: '五', value: '五' },
                            { label: '六', value: '六' },
                          ]}
                          style={{ width: '80px', marginRight: '8px' }}
                        />
                        <span>
                          项情形，依据《市场监督管理投诉举报处理暂行办法》的规定，我局（所）决定不予受理。
                        </span>
                      </div>

                      <div style={{ marginLeft: '24px', lineHeight: '1.8' }}>
                        <div>
                          (一)投诉事项不属于市场监督管理部门职责，或者本行政机关不具有处理权限的；
                        </div>
                        <div>
                          (二)法院、仲裁机构、市场监督管理部门或者其他行政机关、消费者协会或者依法成立的其他调解组织已经受理或者处理过同一消费者权益争议的；
                        </div>
                        <div>
                          (三)不是为生活消费需要购买、使用商品或者接受服务，或者不能证明与被投诉人之间存在消费者权益争议的；
                        </div>
                        <div>
                          (四)除法律另有规定外，投诉人知道或者应当知道自己的权益受到被投诉人侵害之日起超过三年的；
                        </div>
                        <div>
                          (五)未提供《市场监督管理投诉举报处理暂行办法》第九条第一款和第十条规定的材料的；
                        </div>
                        <div>(六)法律、法规、规章规定不予受理投诉的其他情形。</div>
                      </div>
                    </div>
                  </ProForm.Item>
                );
              } else if (isAcceptance === '1') {
                return (
                  <>
                    <ProFormSelect
                      name="contactPerson"
                      label="联系人"
                      tooltip={'默认选择前两个'}
                      initialValue={contactPhoneList}
                      fieldProps={{
                        mode: 'tags',
                        onChange: (values) => {
                          // 根据选择的联系人获取对应的电话号码
                          const phones = values.map(
                            (person: string) => contactPhoneMap[person] || '',
                          );

                          // 更新表单中的联系电话字段
                          formRef.current?.setFieldsValue({
                            contactPhone: phones,
                          });
                        },
                      }}
                      width="md"
                      options={contactPhoneList.map((item) => ({
                        label: item,
                        value: item,
                      }))}
                    />
                    <ProFormSelect
                      disabled={true}
                      name="contactPhone"
                      initialValue={contactNameList}
                      label="联系电话"
                      fieldProps={{
                        mode: 'tags',
                      }}
                      width="md"
                      options={contactNameList.map((item) => ({
                        label: item,
                        value: item,
                      }))}
                    />
                    <ProFormDatePicker
                      name={['mediateDate']}
                      label="调解终止日期"
                      width="md"
                      placeholder="请选择调解终止日期"
                      rules={[{ required: true, message: '请选择调解终止日期' }]}
                    />
                    <ProForm.Item
                      name="acceptanceSituation"
                      label="调解终止所属情形"
                      rules={[{ required: true, message: '请选择调解终止所属情形' }]}
                    >
                      <div style={{ display: 'flex', flexDirection: 'column' }}>
                        <div style={{ display: 'flex', alignItems: 'baseline' }}>
                          <span style={{ marginRight: '4px' }}>投诉的调解过程中出现以下第</span>
                          <ProFormSelect
                            name={['acceptanceSituation']}
                            width="xs"
                            placeholder="请选择"
                            options={[
                              { label: '一', value: '一' },
                              { label: '二', value: '二' },
                              { label: '三', value: '三' },
                              { label: '四', value: '四' },
                              { label: '五', value: '五' },
                              { label: '六', value: '六' },
                              { label: '七', value: '七' },
                            ]}
                            style={{ width: '80px', marginRight: '4px' }}
                          />
                          <span>
                            项情形，依据《市场监督管理投诉举报处理暂行办法》的规定，我局决定终止调解。
                          </span>
                        </div>

                        <div style={{ marginLeft: '24px', lineHeight: '1.8' }}>
                          <div>（一）投诉人撤回投诉或者双方自行和解的；</div>
                          <div>
                            （二）投诉人与被投诉人对委托承担检定、检验、检测、鉴定工作的技术机构或者费用承担无法协商一致的；
                          </div>
                          <div>
                            （三）投诉人或者被投诉人无正当理由不参加调解，或者被投诉人明确拒绝调解的；
                          </div>
                          <div>
                            （四）经组织调解，投诉人或者被投诉人明确表示无法达成调解协议的；
                          </div>
                          <div>
                            （五）自投诉受理之日起四十五个工作日内投诉人和被投诉人未能达成调解协议的；
                          </div>
                          <div>
                            （六）市场监督管理部门受理投诉后，发现存在《市场监督管理投诉举报处理暂行办法》第十五条规定情形的；
                          </div>
                          <div>（七）法律、法规、规章规定应当终止调解的其他情形。</div>
                        </div>
                      </div>
                    </ProForm.Item>
                  </>
                );
              }
              return null;
            }}
          </ProFormDependency>
        </ProForm.Group>
      </StepsForm.StepForm>
      <StepsForm.StepForm name="filing" title="投诉立案">
        {/* 被投诉人统一社会信用代码和法定代表人信息回显 */}
        <ProForm.Group>
          <ProFormText
            name={['agentInfo', 'creditCode']}
            label="被投诉人统一社会信用代码"
            width="md"
            disabled
            tooltip="回显案件信息录入时填写的信息，不可修改"
          >
            <Typography.Text disabled>{creditCode}</Typography.Text>
          </ProFormText>
          <ProFormText
            name={['agentInfo', 'contactPerson']}
            label="法定代表人（负责人）"
            width="md"
            disabled
            tooltip="回显案件信息录入时填写的信息，不可修改"
          >
            <Typography.Text disabled>{contactPerson}</Typography.Text>
          </ProFormText>
        </ProForm.Group>

        {/* 核查结果 */}
        <ProFormRadio.Group
          label={'核查结果'}
          name={['registerAcceptance', 'isRegister']}
          initialValue={'0'}
          options={[
            {
              label: '不予立案',
              value: '0',
            },
            {
              label: '建议立案',
              value: '1',
            },
          ]}
        />

        {/* 案由 */}
        <ProForm.Group>
          <ProForm.Item
            name={['registerAcceptance', 'cause']}
            label="案由"
            rules={[
              { required: true, message: '请输入案由' },
              { max: 1000, message: '案由不能超过1000个字符' },
            ]}
          >
            <div style={{ display: 'flex' }}>
              <ProFormTextArea
                name={['registerAcceptance', 'cause']}
                width="xl"
                placeholder="请输入案由"
              />
              <a
                style={{ marginLeft: '8px', color: '#1890ff' }}
                onClick={() => {
                  Modal.info({
                    title: '争议事实',
                    width: 600,
                    content: (
                      <div style={{ maxHeight: '400px', overflow: 'auto' }}>
                        {complaintDescValue || '暂无争议事实'}
                      </div>
                    ),
                  });
                }}
              >
                查看争议事实
              </a>
            </div>
          </ProForm.Item>

          <ProFormDependency name={['registerAcceptance', 'isRegister']}>
            {({ registerAcceptance }) => {
              if (registerAcceptance.isRegister === '0') {
                return (
                  // 不予立案告知日期
                  <ProFormDatePicker
                    name={['registerAcceptance', 'registerDate']}
                    label="不予立案告知日期"
                    width="md"
                    placeholder="请选择不予立案告知日期"
                    rules={[{ required: true, message: '请选择不予立案告知日期' }]}
                  />
                );
              } else if (registerAcceptance.isRegister === '1') {
                return (
                  <ProFormDatePicker
                    name={['registerAcceptance', 'registerDate']}
                    label="立案告知日期"
                    width="md"
                    placeholder="请选择立案告知日期"
                    rules={[{ required: true, message: '请选择立案告知日期' }]}
                  />
                );
              }
            }}
          </ProFormDependency>

          {/*/////////////////*/}
          <ProFormDependency name={['registerAcceptance', 'isRegister']}>
            {({ registerAcceptance }) => {
              if (registerAcceptance.isRegister === '0') {
                return (
                  // 核查情况及不予立案理由
                  <ProForm.Item
                    name={['registerAcceptance', 'situation']}
                    label="核查情况及不予立案理由"
                    rules={[{ required: true, message: '请输入核查情况及不予立案理由' }]}
                  >
                    <div style={{ display: 'flex', flexDirection: 'column' }}>
                      <div style={{ marginBottom: '16px' }}>
                        <ProFormText
                          name={['registerAcceptance', 'situation']}
                          width="xl"
                          placeholder="请输入法律条款"
                          initialValue="《中华人民共和国食品安全法》第六十七条第三款"
                          fieldProps={{
                            maxLength: 1000,
                            showCount: true,
                          }}
                        />
                        <div>
                          ，建议不予立案。依据《市场监督管理行政处罚程序规定》第十八条第一款之规定，请领导批。
                        </div>
                      </div>
                    </div>
                  </ProForm.Item>
                );
              } else if (registerAcceptance.isRegister === '1') {
                return (
                  <ProForm.Item
                    name={['registerAcceptance', 'situation']}
                    label="经初步调查（检查）当事人的行为涉嫌违反了"
                    rules={[
                      { required: true, message: '请输入经初步调查（检查）当事人的行为涉嫌违反' },
                    ]}
                  >
                    <div style={{ display: 'flex', flexDirection: 'column' }}>
                      <div style={{ marginBottom: '16px' }}>
                        <ProFormText
                          name={['registerAcceptance', 'situation']}
                          width="xl"
                          placeholder="请输入法律条款"
                          initialValue="《中华人民共和国食品安全法》第六十七条第三款"
                          fieldProps={{
                            maxLength: 1000,
                            showCount: true,
                          }}
                        />
                        <div>
                          的规定。符合《市场监督管理行政处罚程序规定》第十九条第一款规定的立案条件，建议立案调查。依据《市场监督管理行政处罚程序规定》第十八条第一款、第十九条第二款之处，请领导审批。
                        </div>
                      </div>
                    </div>
                  </ProForm.Item>
                );
              }
            }}
          </ProFormDependency>
        </ProForm.Group>
      </StepsForm.StepForm>
    </StepsForm>
  );
};
export default CreateModal;
